package com.codeduck.contorller;

import com.codeduck.service.HealthCheckService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("check")
public class IndexController {

    @Resource
    private HealthCheckService healthCheckService;

    @GetMapping("test")
    public String test() {
        return "hello";
    }
    @GetMapping("health")
    public String healthCheck(@RequestParam("idx") String idx) {
        String rs = "@@health@@";
        if (healthCheckService.dbCheck(idx) != 0) {
            rs = "数据库连接异常！";
        }

        if (healthCheckService.fsCheck() != 0) {
            rs = "磁盘异常！";
        }
        return rs + idx;
    }
}
